home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- *
- * Apple Macintosh Developer Technical Support
- *
- * Installer 3.1 sample: User Functions
- *
- * File: UserFunction.c - c Source
- *
- * by: Jon Zap
- * updated for use with Installer 3.4 by: Rich Kubota 9/1/92
- *
- * Copyright © 1988-1990 Apple Computer, Inc.
- * All rights reserved.
- *
- *----------------------------------------------------------------------------*/
- #if 0
- c -b CheckTgtFreeSpace.c
- Link -ra =resPurgeable -rt infn=1001 -rn -m CHECKTGTFREESPACE -t rsrc -c RSED ∂
- CheckTgtFreeSpace.c.o ∂
- "{Libraries}"Interface.o ∂
- -o CheckTgtFreeSpace.rsrc
- #endif
-
- /* applec is only defined by MPW C so we can use it to make versions that work
- with MPW C and THINK C
- */
- #ifdef applec
-
- #include <Files.h>
- #endif
-
- pascal Boolean CheckTgtFreeSpace(short targetVRefNum, long blessedID, long spaceRequired)
- {
- #pragma unused (blessedID)
- ParamBlockRec pb;
- OSErr err;
-
- pb.volumeParam.ioCompletion = nil; // synchronous call
- pb.volumeParam.ioNamePtr = nil; // searching only by vRefNum
- pb.volumeParam.ioVRefNum = targetVRefNum; // get info on this volume
- pb.volumeParam.ioVolIndex = 0; // access volume by vRefNum only
-
- // parameter block is set, so let's do it synchronously
- err = PBGetVInfo(&pb, false);
- if (err)
- return false; // error occured accessing volume, this shouldn't happen
-
- return ( spaceRequired < pb.volumeParam.ioVFrBlk * pb.volumeParam.ioVAlBlkSiz);
- // ioVFrBlk is the number of free allocation blocks on the target disk
- // ioVAlBlkSiz is the number of bytes per allocation block
- // the product of these two values is the amount of free space.
- }